﻿<%@ Page Title="Редактирование маршрута" Language="C#" MasterPageFile="~/Masters/AdminSchedule.master" AutoEventWireup="true"
		 CodeFile="RouteEdit.aspx.cs" Inherits="Pages_RouteEdit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" Runat="Server">
	<link rel="stylesheet" type="text/css" media="screen" href="../../styles/EntityEditStyle.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphContent" Runat="Server">
	<a href='<%= ResolveUrl("~/Pages/Carrier/Route.aspx") %>'>Вернуться к списку маршрутов</a>
	<div style="width:100%;">
		<asp:Label runat="server" ID="lbMessage" />
		<asp:ValidationSummary ID="vsRouteSave" runat="server" ValidationGroup="vgSave" CssClass="ValidationSummary" />
	</div>
	<div class="edit-form">
		<div class="edit-row">
			<div class="edit-label">Название маршрута</div>
			<div class="edit-control">
				<asp:TextBox runat="server" ID="tbRouteName" />
				<asp:RequiredFieldValidator ID="rfvRouteName" runat="server" ControlToValidate="tbRouteName" ValidationGroup="vgSave" Text="*" ErrorMessage="Не указано название маршрута" EnableClientScript="false">
				</asp:RequiredFieldValidator>
			</div>
		</div>
		<asp:UpdatePanel runat="server" ID="upRoute" UpdateMode="Conditional">
			<ContentTemplate>
				<div class="edit-row">
					<div class="edit-label">Остановка отправления</div>
					<div class="edit-control">
						<asp:Label runat="server" ID="lbSourceStation" />
						<asp:HiddenField runat="server" ID="hfSourceStation" />
						<asp:LinkButton runat="server" ID="lkbEditSourceStation" Text="[Изменить]" 
										OnClick="OnEditStation" CommandName="SourceStation" />
					</div>
				</div>
				<div class="edit-row">
					<div class="edit-label">Остановка прибытия</div>
					<div class="edit-control">
						<asp:Label runat="server" ID="lbTargetStation" />
						<asp:HiddenField runat="server" ID="hfTargetStation" />
						<asp:LinkButton runat="server" ID="lkbEditTargetStation" Text="[Изменить]" 
										OnClick="OnEditStation" CommandName="TargetStation" />
					</div>
				</div>
				<div class="edit-row">
					<div class="edit-label">Промежуточные остановки</div>
					<div class="edit-control">
						<asp:Repeater runat="server" ID="rptRouteStation">
							<ItemTemplate>
								<%# string.Format("{0} <i><br />{1} км, {2} ч,<br /> {3}</i>", Eval("station.Name")
													, Eval("Distance")
													, Eval("TimeDistance")
													, Eval("LandingPlace")) %>
								<asp:LinkButton runat="server" ID="lkbEditRouteStation" Text="[Удалить]" CommandArgument='<%# Eval("station.Id") %>'
												OnClick="OnDeleteStation" />
								<br />
							</ItemTemplate>
						</asp:Repeater>
					</div>
				</div>
				<div class="edit-row">
					<div class="edit-label">
						<a href="RouteEditStations.aspx" runat="server" id="aRouteEditStations" visible="false">Редактировать промежуточные остановки</a>
					</div>
					<div class="edit-control">
						<asp:LinkButton runat="server" ID="lkbAddRouteStation" Text="Добавить" 
										OnClick="OnEditStation" CommandName="RouteStation" />
					</div>
				</div>
			</ContentTemplate>
		</asp:UpdatePanel>
	</div>
	<div class="buttons">
		<asp:Button runat="server" ID="btnSave" Text="Сохранить" OnClick="OnRouteSave" ValidationGroup="vgSave" />
		<asp:Button runat="server" ID="btnCancel" Text="Отменить" OnClick="OnCancel" />
	</div>
	
	<div id="modal" runat="server" class="modaldiv" style="display:none;">
		<asp:UpdatePanel runat="server" ID="upStation">
			<ContentTemplate>
				<asp:TextBox runat="server" ID="tbSearchStation" Width="250" AutoPostBack="true"
							OnTextChanged="OnSearchStation" />
				<asp:LinkButton runat="server" ID="lkbAddNewStation" Text="Добавить"
								OnClick="OnAddNewStation" />
				<br />
				<asp:Repeater runat="server" ID="rptStation">
					<ItemTemplate>
						<asp:LinkButton runat="server" ID="lkbStation" Text='<%# Eval("Name") %>'
										CommandArgument='<%# Eval("Id") %>' OnClick="AddStation" /><br />
					</ItemTemplate>
				</asp:Repeater>
				<asp:HiddenField runat="server" ID="hfModalAction" />
			</ContentTemplate>
		</asp:UpdatePanel>
		<div style="text-align: right;">
			<asp:Button runat="server" ID="btnModalClose" Text="Закрыть" />
		</div>
	</div>
	<asp:LinkButton Text="" runat="server" ID="lnkPopup" />
	<ajax:ModalPopupExtender ID="MPE" runat="server" PopupControlID="modal" TargetControlID="lnkPopup"
		CancelControlID="btnModalClose" BehaviorID="MPEbeh" BackgroundCssClass="ui-modal-overlay"
		OkControlID="btnModalClose" />
</asp:Content>

